package com.tgy.ailiyun.controller;

import com.tgy.ailiyun.entity.Student;
import com.tgy.ailiyun.service.impl.StudentServiceImpl;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/student")
public class StudentCotroller {
    @Resource
    StudentServiceImpl studentService;

    @RequestMapping("/list")
    public String studentList(){
        return "studentList";
    }

    @RequestMapping("/select")
    @ResponseBody
    public Map<String, Object> getByEntity(@RequestBody Student student){
        return this.studentService.getAll(student);
    }

    @RequestMapping("/add")
    @ResponseBody
    public Map<String, Object> add(@RequestBody Student student){
        return this.studentService.add(student);
    }

    @GetMapping("/delById")
    @ResponseBody
    public Map<String, Object> delById(@RequestParam("id") Integer id){
        return this.studentService.delById(id);
    }

    @RequestMapping("/upd")
    @ResponseBody
    public HashMap<String, Object> upd(@RequestBody Student student){
        return this.studentService.upd(student);
    }
}
